package com.jy.event.domain;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import java.util.Date;

/**
 * Created by hanxi on 2017/7/8.
 */
@Entity
@Data
@NoArgsConstructor
public class
Product {
    @Id
    @Column(length = 50)
    private String id;
    private String storeId;
    private String name;
    private String pinyin;
    private String barCode;
    @ManyToOne
    private ProductType productType;
    private double costPrice = 0;
    private Double salesPrice;
    private String supplierName;
    private ProductStatus productStatus;
    private String imageURL;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3)")
    private Date addTime;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)")
    private Date updateTime;
    private boolean enabled = true;
    @Column(columnDefinition = "int(11) NOT NULL DEFAULT 0")
    private int quantity = 0;
    /**
     * 零售单位与库存单位的比率。比如一条烟等于10包，该值为10
     */
    @Column(columnDefinition = "INT(6) DEFAULT 1")
    private int stockQuantityRatio = 1;
    /**
     * 库存单位价格
     */
    @Column(columnDefinition = "DECIMAL(11,2) DEFAULT 0")
    private double stockPrice = 0;
    @Column(columnDefinition = "TIMESTAMP(3) NULL")
    private Date lastCheckTime;
    @Column(columnDefinition = "TIMESTAMP(3) NULL")
    private Date lastStockInTime;
    /**
     * 是否管理库存
     */
    private boolean isStockEnabled = true;
    /**
     * 是否允许会员赠送金额支付
     */
    @Column(columnDefinition = "BIT(1) DEFAULT 0")
    private boolean allowMemberBonusPay = false;

    /**
     * 固定提成金额
     */
    private double commission = 0;

    /**
     * 是否管理原材料
     */
    @Column(name = "is_material_enabled")
    private boolean materialEnabled = false;

//    /**
//     * 原料列表
//     */
//    @OneToMany(orphanRemoval = true)
//    @JoinColumn(name = "PRODUCT_ID")
//    @OrderBy(value = "addTime")
//    private List<MaterialItem> materials = new ArrayList<>();

    /**
     * 是否支持厨房打印
     */
    private boolean kitchenPrintEnabled = false;

}
